package jp.co.cos.ittrick.channel.controller.admin.file;

import jp.co.cos.ittrick.channel.model.FileModel;
import jp.co.cos.ittrick.channel.service.FileService;

import org.slim3.controller.Controller;
import org.slim3.controller.Navigation;

public class DownloadController extends Controller {

	private FileService service = new FileService();

    @Override
    public Navigation run() throws Exception {

    	String pkKey = asString("key");
    	FileModel data = service.getData(Integer.valueOf(pkKey));
        byte[] bytes = service.getBytes(data);
        download(data.getFileName(), bytes);
        return null;
    }

}
